print("Введите скобочную последовательность:")
def check_brackets(string):
    x = []
    opening_brackets = ['(', '[', '{']
    closing_brackets = [')', ']', '}']
    
    for char in string:
        if char in opening_brackets:
            x.append(char)
        elif char in closing_brackets:
            if len(x) == 0:
                return False
            if opening_brackets.index(x.pop()) != closing_brackets.index(char):
                return False
    
    return len(x) == 0

bracket_string = input()
if check_brackets(bracket_string):
    print("True")
else:
    print("False")


